<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Stream_Api extends CI_Controller {

    public function index() {
        $this->load->helper(array('html'));

        $this->output->set_content_type('application/json');

        $data = $this->getMockStreamData();
        $this->output->set_output(json_encode($data));
    }

    function getMockStreamData() {
        $data = <<<DATA
            {"result" : [
                {
                    "item_id" : "1",
                    "title" : "Need some suggestion on 10.1 holiday plan",
                    "author" : {
                        "username" : "alo",
                        "img_url"  : "http://www.apple.com/apple-touch-icon.png"
                    },
                    "comment_count" : "34",
                    "visited_count" : "200",
                    "voted_count" : "54",
                    "description" : "Where to go?",
                    "options" : [
                        {
                            "index" : "A",
                            "description" : "Beijing",
                            "voted_count" : 12
                        },
                        {
                            "index" : "B",
                            "description" : "Shanghai",
                            "voted_count" : 20
                        },
                        {
                            "index" : "C",
                            "description" : "Guangzhou",
                            "voted_count" : 11
                        }
                    ]
                },
                {
                    "item_id" : "2",
                    "title" : "Need some suggestion on 10.1 holiday plan",
                    "author" : {
                        "username" : "alo",
                        "img_url"  : "http://www.apple.com/apple-touch-icon.png"
                    },
                    "comment_count" : "34",
                    "visited_count" : "200",
                    "voted_count" : "54",
                    "description" : "Where to go?",
                    "options" : [
                        {
                            "index" : "A",
                            "description" : "Beijing",
                            "voted_count" : 12
                        },
                        {
                            "index" : "B",
                            "description" : "Shanghai",
                            "voted_count" : 20
                        },
                        {
                            "index" : "C",
                            "description" : "Guangzhou",
                            "voted_count" : 11
                        }
                    ]
                },
                {
                    "item_id" : "3",
                    "title" : "Need some suggestion on 10.1 holiday plan",
                    "author" : {
                        "username" : "alo",
                        "img_url"  : "http://www.apple.com/apple-touch-icon.png"
                    },
                    "comment_count" : "34",
                    "visited_count" : "200",
                    "voted_count" : "54",
                    "description" : "Where to go?",
                    "options" : [
                        {
                            "index" : "A",
                            "description" : "Beijing",
                            "voted_count" : 12
                        },
                        {
                            "index" : "B",
                            "description" : "Shanghai",
                            "voted_count" : 20
                        },
                        {
                            "index" : "C",
                            "description" : "Guangzhou",
                            "voted_count" : 11
                        }
                    ]
                },
                {
                    "item_id" : "4",
                    "title" : "Need some suggestion on 10.1 holiday plan",
                    "author" : {
                        "username" : "alo",
                        "img_url"  : "http://www.apple.com/apple-touch-icon.png"
                    },
                    "comment_count" : "34",
                    "visited_count" : "200",
                    "voted_count" : "54",
                    "description" : "Where to go?",
                    "options" : [
                        {
                            "index" : "A",
                            "description" : "Beijing",
                            "voted_count" : 12
                        },
                        {
                            "index" : "B",
                            "description" : "Shanghai",
                            "voted_count" : 20
                        },
                        {
                            "index" : "C",
                            "description" : "Guangzhou",
                            "voted_count" : 11
                        }
                    ]
                },
                {
                    "item_id" : "5",
                    "title" : "Need some suggestion on 10.1 holiday plan",
                    "author" : {
                        "username" : "alo",
                        "img_url"  : "http://www.apple.com/apple-touch-icon.png"
                    },
                    "comment_count" : "34",
                    "visited_count" : "200",
                    "voted_count" : "54",
                    "description" : "Where to go?",
                    "options" : [
                        {
                            "index" : "A",
                            "description" : "Beijing",
                            "voted_count" : 12
                        },
                        {
                            "index" : "B",
                            "description" : "Shanghai",
                            "voted_count" : 20
                        },
                        {
                            "index" : "C",
                            "description" : "Guangzhou",
                            "voted_count" : 11
                        }
                    ]
                }

            ]}
DATA;
        return json_decode($data)->{'result'};
    }
}
